<?php
//wondershare公司类
//用于写产品的相关替换函数
include(dirname(__FILE__).'/../public/public_company.php');
class WondershareCompany  extends PublicCompany {
	function __construct($arr = NULL){
		
	}
	function news_article($db,$get = array())
	{
		$limit = empty($get['limit'])?2:(int)trim(htmlspecialchars($get['limit']));
		$type = empty($get['type'])?'':trim(htmlspecialchars($get['type']));
		$orderStr = ' ORDER BY  a.created ';
		switch ($type)//取文章类型
		{
			case 'is_new'://表示取最新
			$orderStr = ' ORDER BY  a.created ';
			break; 
		
		}
		$str = '';
		$sql ='SELECT tab.url,a.title,a.created,a.summary FROM article_info a  
		LEFT JOIN Table_125 tab ON a.id = tab.Field_21524   '.$orderStr.' LIMIT  '.$limit;
		$res = $db->query($sql);
		if(!$res){throw $messge;}
		while ($row = $db->fetch_array($res)) {
			$created = date ("F d, Y " ,strtotime($row['created']));
			$url = str_replace(array('/wondershare.com/httpdocs','/index.html'),array('http://www.wondershare.com',''),$row['url']);
			$str.='<div class="mainContent"><div class="newsRoom"> <div class="newsRoomList">
			<a class="news_title" id="news_20" href="'.$url.'"><span style="font-size:16px;">'
			.$row['title'].'</span><span> - '.$created .'</span></a>
			<div class="newsRoom_info clear">'.$row['summary'].'</div>
			</div></div> </div>';
		}

		unset($row);
		return  $str;

	}
	
	//得到年份相关文章
	function year_article($db,$get = array())
	{
		$start_year = empty($_GET['start_year'])?'2011-01-01 00:00:00':(int)trim(htmlspecialchars($get['start_year'])).'-01-01 00:00:00';
		$end_year = empty($_GET['end_year'])?'2012-01-01 00:00:00':(int)trim(htmlspecialchars($get['end_year'])).'-01-01 00:00:00';
		$limit = empty($_GET['limit'])?10:(int)trim(htmlspecialchars($get['limit']));
		$str = '';
		$sql ='SELECT tab.url,a.title,a.created,a.summary FROM article_info a  LEFT JOIN Table_125 tab ON 
		a.id = tab.Field_21524  WHERE a.created >= "'.$start_year.'" AND  a.created < "'.$end_year.'" 
		ORDER BY  a.created DESC LIMIT '.$limit;
		$res = $db->query($sql);
		while ($row = $db->fetch_array($res)) {
			$created = date ("F d, Y " ,strtotime($row['created']));
			$url = str_replace(array('/wondershare.com/httpdocs','/index.html'),array('http://www.wondershare.com',''),$row['url']);
			$str .= '<a class="news_title" id="news_20" href="'.$url.'"><span style="font-size:16px;">'.$row['title'].
			'</span><span> - '.$created.'</span></a><div class="newsRoom_info clear">'.$row['summary'].
			'<div align="right"></div> </div>';
		}
		unset($row);
		return  $str;
	}
}
?>